package com.sport.controller;

import com.google.gson.Gson;
import com.sport.pojo.vo.JudgeVerifyVo;
import com.sport.pojo.vo.StudentVerifyVo;
import com.sport.result.Result;
import com.sport.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/manager")
@Api(tags = "管理端相关接口")
public class ManageController {
    @Autowired
    private UserService userService;
    @ApiOperation("查询学生认证申请列表")
    @GetMapping("/findStudentVerification")
    public Result findStudentVerification() {
        List<StudentVerifyVo> list = userService.findStudentVerification();
        return Result.success(new Gson().toJson(list));
    }
    @ApiOperation("查询裁判认证申请列表")
    @GetMapping("/findJudgeVerification")
    public Result findJudgeVerification(){
        List<JudgeVerifyVo> list =   userService.findJudgeVerification();
        return Result.success(new Gson().toJson(list));
    }
    @ApiOperation("同意学生认证申请")
    @PostMapping("/agreeStudentVerification")
    public Result agreeStudentVerification(String userId){
        if(userService.agreeStudentVerification(userId)!=0){
            return Result.success();
        }
        return Result.error("");
    }
    @ApiOperation("同意裁判认证申请")
    @PostMapping("/agreeJudgeVerification")
    public Result agreeJudgeVerification(String userId){
        if(userService.agreeJudgeVerification(userId)!=0){
            return Result.success();
        }
        return Result.error("");
    }
    @ApiOperation("不同意学生认证申请")
    @PostMapping("/disagreeStudentVerification")
    public Result disagreeStudentVerification(String userId){
        if(userService.disagreeStudentVerification(userId)!=0){
            return Result.success();
        }
        return Result.error("");
    }
    @ApiOperation("不同意裁判认证申请")
    @PostMapping("/disagreeJudgeVerification")
    public Result disagreeJudgeVerification(String userId){
        if(userService.disagreeJudgeVerification(userId)!=0){
            return Result.success();
        }
        return Result.error("");
    }

}
